# Contributor: Jason Qiu <jasonwqiu@gmail.com>

_realname=pycountry
pkgbase=mingw-w64-python-${_realname}
pkgver=22.3.5
pkgrel=2
pkgdesc="ISO country, subdivision, language, currency and script definitions and their translations"
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://pypi.org/project/pycountry/"
license=('LGPL2.1')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-lxml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest" 
              "${MINGW_PACKAGE_PREFIX}-python-pytest-runner")
source=("${_realname}-${pkgver}.tar.gz::https://pypi.io/packages/source/p/pycountry/pycountry-${pkgver}.tar.gz")
sha512sums=('07dc507ee94f1880727761df197f81704386d9246163c9a5872f47083d37c7d1205dfbd28c6663ef0731a0b05277ade03a1a1929ab84087e0e85c05028c68b89')

prepare() {
    cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build 
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py pytest
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix="${MINGW_PREFIX}" \
        --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}"/share/licenses/python-${_realname}/LICENSE
}
